<template>
	
	
	<!--废弃-->
	
	
	<!--<div>-->
		 <!--横向变换(改完字段)-->
		<!--<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>-->
	   <!-- <div style="padding: 20px;">-->
	       
	       <!--<div style="margin:5px 0px 0px 0px;background-color: #f5f5f5;padding: 20px;">
				<Row >
			        <Col span="24" style="text-align: left;">
						<span style="font-size: 18px;color: #1a1a1a;font-weight: 540;">评价名称：{{excelname}}</span>
					</Col>
				</Row>
				<Row style="margin:15px 0px 0px 0px;color: #666666;">
			        <Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">年级：{{gradeName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">基数：{{baseExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">本次：{{thisExamName}}</span>
					</Col>
					<Col span="6" style="text-align: left;">
						<span style="font-size: 16px;">时间：{{createTime}}</span>
					</Col>
				</Row>
			</div>-->
			<!--<Row >
		        <Col span="24" style="text-align: right;margin-bottom:10px;">
		        	<Button style="background-color: #4496fc;" size="small" :loading="loading" @click="exportexl">
		        		<span v-if="!loading"><img style="width: 20px;margin-top: 2px;" src="../../../../../../static/img/export.png" alt="" /></span>
				        <span v-else>加载中</span>
		        	</Button>
		        </Col>
		    </Row>
	        <v-table :min-height='500' :is-loading="loadingShow" style="width:100%"  is-horizontal-resize is-vertical-resize :title-rows="titleRows" :columns="columns" :table-data="tableData" :cell-merge="cellMerge"></v-table>
	    </div>
	</div>-->
</template>

<script>
	import { getsessionstorage } from '@/components/js/Localstorage'
	import api from "@/components/js/Apidomain.js"
    export default {
        data() {
            return {
            	excelname:"",			//查询的名字
				gradeName:"",			//查询的年级
				baseExamName:"",		//查询的基数考试名字
				thisExamName:"",		//查询的本次考试名字
				createTime:"",			//查询的评价时间
            	
            	loadingShow:false,				//表格获取的加载中显示隐藏
            	
            	loading: false,				//下载模板按钮上的加载中显示隐藏
            	
            	allclasses:[],					//表格里面的所有班级，用于表格第一列合并
            	allbasechiarr:[],
            	basearr:[
            		{key:'baseChiNum',value:[]},
            		{key:'baseMathNum',value:[]},
            		{key:'baseEngNum',value:[]},
            		{key:'basePhyNum',value:[]},
            		{key:'baseChemNum',value:[]},
            		{key:'baseBioNum',value:[]},
            		{key:'basePolNum',value:[]},
            		{key:'baseHisNum',value:[]},
            		{key:'baseGeoNum',value:[]},
            	],
            	
				titleRows: [
                             [{fields: ['classesNo'], title: '班级', titleAlign: 'center', rowspan: 2,colspan: 1},
                              {fields: ["levelName"], title: '层级', titleAlign: 'center', rowspan: 2,colspan: 1},
                              {fields: ["baseValue"], title: '基数人数', titleAlign: 'center', rowspan: 2,colspan: 1},
                              {fields: ["thisValue"], title: '本次人数', titleAlign: 'center', rowspan: 2,colspan: 1},
                              
                              {fields: ['thisUp', 'keepThis','thisDown'], title: '本层级升降情况', titleAlign: 'center', colspan: 3},
                              {fields: ['upThis', 'downThis'], title: '其他层级升降情况', titleAlign: 'center', colspan: 2},
                              
                            ],
                            [	
                            	{fields: ['thisUp'], title: '基数', titleAlign: 'center'},
                              	{fields: ['keepThis'], title: '本次', titleAlign: 'center'},
                              	{fields: ['thisDown'], title: '本次', titleAlign: 'center'},
                              	{fields: ['upThis'], title: '基数', titleAlign: 'center'},
                              	{fields: ['downThis'], title: '本次', titleAlign: 'center'},
                              	
                            ],

                             
                ],
                columns: [
                    {field: 'classesNo', width: 50, titleAlign: 'center', columnAlign: 'center',isResize:true},
                    {field: 'levelName', width: 50, titleAlign: 'center', columnAlign: 'center',isResize:true},
                    {field: 'baseValue', width: 50, titleAlign: 'center', columnAlign: 'center',isResize:true},
                    {field: 'thisValue', width: 50, titleAlign: 'center', columnAlign: 'center',isResize:true},
                    
                    
                    {field: 'thisUp', width: 50, columnAlign: 'center',isResize:true},
                    {field: 'keepThis', width: 50, columnAlign: 'center' ,isResize:true},
                    {field: 'thisDown', width: 50, columnAlign: 'center' ,isResize:true},
                    {field: 'upThis', width: 50, columnAlign: 'center' ,isResize:true},
                    {field: 'downThis', width: 50, columnAlign: 'center',isResize:true},
                    
                    
                    
                ],
                tableData: [
//                      {"classesNo":"1班","levelName":"A层","thisGradeName":"A数","baseChiNum":"50","thisChiNum":"183","baseMathNum":"zhao","thisMathNum":"1561987","baseEngNum":"钢琴唱歌","thisEngNum":"黄浦区金陵东路569号17楼"},  
                ],
            }
        },
        created(){
        	
		},
		mounted(){
			this.excelname = getsessionstorage('excelname')
			this.gradeName = getsessionstorage('gradeName')
			this.baseExamName = getsessionstorage('baseExamName')
			this.thisExamName = getsessionstorage('thisExamName')
			this.createTime = getsessionstorage('createTime')
			
		},
		computed: {
			
		},
        methods: {
        	gettablelist:function(){
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId')
				
				if(sessionroleid && sessionperformId){
					this.loadingShow = true;
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaHorizontalChange/listDto/'+sessionperformId+'/'+sessionroleid;
	            	this.$http.post(url).then(function(response) {
						if(response.data.success == true){

//		            		////console.log(response.data.data)
							self.tableData = response.data.data

							//获取所有班级（不重复）
							var firstclassarr = []
							for(let key in self.tableData){
								if(firstclassarr.indexOf(self.tableData[key].classesNo) == -1){
									firstclassarr.push(self.tableData[key].classesNo);
								}
							}
							self.allclasses = firstclassarr;
							
							
							
							
							//获取所有基数（跨度为4）
//							
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].baseChiNum){
									self.basearr[0].value.push(self.tableData[i].baseChiNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].baseMathNum){
									self.basearr[1].value.push(self.tableData[i].baseMathNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].baseEngNum){
									self.basearr[2].value.push(self.tableData[i].baseEngNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].basePhyNum){
									self.basearr[3].value.push(self.tableData[i].basePhyNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].baseChemNum){
									self.basearr[4].value.push(self.tableData[i].baseChemNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].baseBioNum){
									self.basearr[5].value.push(self.tableData[i].baseBioNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].basePolNum){
									self.basearr[6].value.push(self.tableData[i].basePolNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].baseHisNum){
									self.basearr[7].value.push(self.tableData[i].baseHisNum)
								}
							}
							for(let i = 0;i<self.tableData.length;i=i+4){
								//多一步判断是否为空
								if(self.tableData[i].baseGeoNum){
									self.basearr[8].value.push(self.tableData[i].baseGeoNum)
								}
							}
//							//console.log(self.basearr)
							
							

							self.loadingShow = false;
			            }else if(response.data.success == false){
			            		self.loadingShow = false;
			            		self.$Message.error({
									content: response.data.msg,
									duration: 10,
									closable: true
								});	
			            	}
			            })
						.catch(function(error) {
							self.loadingShow = false;
							self.$Message.error({
								content: '系统发生错误：错误码00164',
								duration: 10,
								closable: true
							});
						});
				}else{
					self.$Message.error({
							content: '系统发生错误：错误码00165',
							duration: 10,
							closable: true
						});
				}
			},
			cellMerge(rowIndex,rowData,field){
//				//console.log(this.allclasses)
//				for(let i = 0;i<this.allclasses.length;i++){
//					if(field === 'classesNo' && rowData[field] === this.allclasses[i]){
//						return {
//							colSpan:1,
//		                    rowSpan:16,
//		                    content: '<span >'+this.allclasses[i]+'</span>',
//		                    componentName: ''
//		                }
//					}
//				}
//				
//				
//				for(let n in this.basearr){
//					for(let i = 0;i<this.basearr[n].value.length;i++){
//						if(field === this.basearr[n].key && rowData[field] === this.basearr[n].value[i]){
//							return {
//								colSpan:1,
//			                    rowSpan:4,
//			                    content: '<span >'+this.basearr[n].value[i]+'</span>',
//			                    componentName: ''
//			                }
//						}
//					}
//				}
//				
//
//				if(field === 'baseGradeName' && rowData[field] === 'A层'){
//					return {
//						colSpan:1,
//	                    rowSpan:4,
//	                    content: '<span >A层</span>',
//	                    componentName: ''
//	                }
//				}
//				if(field === 'baseGradeName' && rowData[field] === 'B层'){
//					return {
//						colSpan:1,
//	                    rowSpan:4,
//	                    content: '<span >B层</span>',
//	                    componentName: ''
//	                }
//				}
//				if(field === 'baseGradeName' && rowData[field] === 'C层'){
//					return {
//						colSpan:1,
//	                    rowSpan:4,
//	                    content: '<span >C层</span>',
//	                    componentName: ''
//	                }
//				}
//				if(field === 'baseGradeName' && rowData[field] === 'D层'){
//					return {
//						colSpan:1,
//	                    rowSpan:4,
//	                    content: '<span >D层</span>',
//	                    componentName: ''
//	                }
//				}
			},
			exportexl:function(){
			
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				
				if(sessionroleid && sessionperformId){
					this.loading = true;
				
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaHorizontalChange/exportExcelDto/'+sessionperformId+'/'+sessionroleid;
	            	this.$http.post(url).then(function(response) {
						if(response.data.success == true){
	//						////console.log(response.data.data)
							window.location.href = response.data.data;
							self.loading = false;
		            }else if(response.data.success == false){
		            		self.loading = false;
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
		            	
					})
					.catch(function(error) {
						self.loading = false;
						self.$Message.error({
							content: '系统发生错误：错误码00166',
							duration: 10,
							closable: true
						});
					});
				}
			}
        }
    }
</script>

<style>

</style>